﻿// $Id$

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Salamanca;
using Salamanca.DataAccess;
using Salamanca.DataAccess.Collections;
using Salamanca.DataActivities;
using Salamanca.DataActivities.UI;
using Salamanca.DataRules;

namespace Northwind.DomainModel.Activities
{



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>Interface implemented by a class that acts as a <see cref="DomainModel.Shipper" /> question factory.</summary>
    ///
    ///////////////////////////////////////////////////////////////////////////

    public partial interface IShipperCrudQuestionFactory
    {
    }



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>Activity state that initializes a new <see cref="DomainModel.Shipper" /> instance.</summary>
    ///
    ///////////////////////////////////////////////////////////////////////////

    public partial class ShipperCreate<TActivityData>:
        ActivityState<TActivityData>
        where TActivityData:
            IActivityData,
            IShipperContainer
    {

        /// <summary>Initializes a new instance of the <see cref="ShipperCreate{TActivityData}" /> class.</summary>
        public ShipperCreate(TActivityData data, IDataActivityParameters parameters):
            this(data, parameters, null)
        {
        }

        /// <summary>Initializes a new instance of the <see cref="ShipperCreate{TActivityData}" /> class.</summary>
        public ShipperCreate(TActivityData data, IDataActivityParameters parameters, NextStateCreateHandler<TActivityData> nextStateCreator):
            base(data, parameters)
        {
            _NextStateCreator=nextStateCreator;
        }

        /// <summary>Performs the actual initialization of a new <see cref="Shipper" /> instance.</summary>
        protected override ActivityStateResult Handle(IActivityController controller)
        {
            return _Handle(controller);
        }

        /// <summary>Gets the next state.</summary>
        protected override IActivityState NextState
        {
            get
            {
                return _NextState;
            }
        }
    }



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>Activity state that asks information about a <see cref="DomainModel.Shipper" /> instance.</summary>
    ///
    ///////////////////////////////////////////////////////////////////////////

    public partial class ShipperAskInfos<TActivityData, TQuestionFactory>:
        QuestionActivityState<TActivityData>
        where TActivityData:
            IActivityData,
            IShipperContainer
        where TQuestionFactory:
            IShipperCrudQuestionFactory
    {

        /// <summary>Initializes a new instance of the <see cref="ShipperAskInfos{TActivityData}" /> class.</summary>
        public ShipperAskInfos(TActivityData data, IQuestionFactoryParameters<TQuestionFactory> parameters):
            this(data, parameters, null)
        {
        }

        /// <summary>Initializes a new instance of the <see cref="ShipperAskInfos{TActivityData}" /> class.</summary>
        public ShipperAskInfos(TActivityData data, IQuestionFactoryParameters<TQuestionFactory> parameters, NextStateCreateHandler<TActivityData> nextStateCreator):
            base(data, parameters)
        {
            _NextStateCreator=nextStateCreator;
        }

        /// <summary>Raises the <see cref="ActivityState{TActivityData}.Initialized" /> event.</summary>
        protected override void OnInitialized(ActivityStateEventArgs e)
        {
            _OnInitialized(e);
        }

        /// <summary>Gets the next state.</summary>
        protected override IActivityState NextState
        {
            get
            {
                return _NextState;
            }
        }
    }



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>Activity state that saves a <see cref="DomainModel.Shipper" /> instance.</summary>
    ///
    ///////////////////////////////////////////////////////////////////////////

    public partial class ShipperSave<TActivityData>:
        ActivityState<TActivityData>
        where TActivityData:
            IActivityData,
            IShipperContainer
    {

        /// <summary>Initializes a new instance of the <see cref="ShipperSave{TActivityData}" /> class.</summary>
        public ShipperSave(TActivityData data, IActivityParameters parameters):
            this(data, parameters, null)
        {
        }

        /// <summary>Initializes a new instance of the <see cref="ShipperSave{TActivityData}" /> class.</summary>
        public ShipperSave(TActivityData data, IActivityParameters parameters, NextStateCreateHandler<TActivityData> nextStateCreator):
            base(data, parameters)
        {
            _NextStateCreator=nextStateCreator;
        }

        /// <summary>Performs the actual saving of the <see cref="Shipper" /> instance.</summary>
        protected override ActivityStateResult Handle(IActivityController controller)
        {
            return _Handle(controller);
        }

        /// <summary>Gets the next state.</summary>
        protected override IActivityState NextState
        {
            get
            {
                return _NextState;
            }
        }
    }



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>Activity state that deletes a <see cref="DomainModel.Shipper" /> instance.</summary>
    ///
    ///////////////////////////////////////////////////////////////////////////

    public partial class ShipperDelete<TActivityData>:
        ActivityState<TActivityData>
        where TActivityData:
            IActivityData,
            IShipperContainer
    {

        /// <summary>Initializes a new instance of the <see cref="ShipperDelete{TActivityData}" /> class.</summary>
        public ShipperDelete(TActivityData data, IActivityParameters parameters):
            this(data, parameters, null)
        {
        }

        /// <summary>Initializes a new instance of the <see cref="ShipperDelete{TActivityData}" /> class.</summary>
        public ShipperDelete(TActivityData data, IActivityParameters parameters, NextStateCreateHandler<TActivityData> nextStateCreator):
            base(data, parameters)
        {
            _NextStateCreator=nextStateCreator;
        }

        /// <summary>Performs the actual deletion of the <see cref="Shipper" /> instance.</summary>
        protected override ActivityStateResult Handle(IActivityController controller)
        {
            return _Handle(controller);
        }

        /// <summary>Gets the next state.</summary>
        protected override IActivityState NextState
        {
            get
            {
                return _NextState;
            }
        }
    }

}
